$(function () {
	//Slide content
    //hide slide content
	$(".slide_content, .mb_panel, .hide").hide();
	//slideDown panel toggle
	$("a.slide_down").click(function (e) {
	    
		var panel_ID = $(this).parent("li").attr("class");
		
		if($(".slide_content").hasClass('active')){
			$('.slide_content').slideUp(200).delay(500).removeClass("active");
			$(".overlay").delay(1000).fadeOut(500).remove();
		}
		else{
			$("#" + panel_ID).css({"z-index": 500}).slideDown('slow').addClass("active");
			$("body").append("<div class='overlay'></div>");
			var docHeight = $(document).height();
			var docWidth = $(document).width();
			$(".overlay").css({
				"height": docHeight,
				"width": docWidth,
				"z-index": 100
			}).fadeIn(500);
		}
		return false;
	});
	
	$(".view_mb").click(function (e) {
		var panel_ID = $(this).parent().parent("li").attr("class");
		if($(".slide_content").hasClass('active')){
			$('.slide_content').slideUp(200).delay(500).removeClass("active");
			$('.miniBasket').css({"z-index": 0})
			$(".overlay").delay(1000).fadeOut(500).remove();
		}
		else{
			$("#" + panel_ID).css({"z-index": 500}).slideDown('slow').addClass("active");
			$('.miniBasket').css({"z-index": 500})
			$(".stickyHeader").append("<div class='overlay'></div>");
			var docHeight = $(document).height();
			var docWidth = $(document).width();
			$(".overlay").css({
				"height": docHeight,
				"width": docWidth,
				"z-index": 200
			}).fadeIn(500);
		}
		return false;
	});
	
	$("a.slide_down_b").click(function (e) {
		var panel_ID = $(this).parent("li").attr("class");
		if($(".slide_content").hasClass('active')){
			$('.slide_content').slideUp(200).delay(500).removeClass("active");
			$('.stickyfooter').css({"z-index": 0})
			$(".overlay").delay(1000).fadeOut(500).remove();
		}
		else{
			$("#" + panel_ID).css({"z-index": 500}).slideDown('slow').addClass("active");
			$('.stickyfooter').css({"z-index": 500})
			$("body").append("<div class='overlay'></div>");
			var docHeight = $(document).height();
			var docWidth = $(document).width();
			$(".overlay").css({
				"height": docHeight,
				"width": docWidth,
				"z-index": 200
			}).fadeIn(500);
		}
		return false;
	});
	
	
	$(".slide_content").hoverIntent({
     over: show,
     timeout: 200,
     out: hide
	});
	function show(){}
	function hide(){
		$('.slide_content').slideUp(200).removeClass("active");
		$(".overlay").delay(1000).fadeOut(500).remove();
		}
	
	$("#mainBody, .banner, .close").click(function () {	
		 if ($(".slide_content").is(':visible')){
			$(".slide_content").slideUp("fast").removeClass("active");
		 }
		 else{}
	});

});